package com.openbravo.pos.printer.escpos;

import com.openbravo.pos.forms.AppLocal;
import com.openbravo.pos.printer.DevicePrinter;
import com.openbravo.pos.printer.TicketPrinterException;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;

public class DevicePrinterESCPOS
  implements DevicePrinter
{
  private PrinterWritter m_CommOutputPrinter;
  private Codes m_codes;
  private UnicodeTranslator m_trans;
  private String m_sName = AppLocal.getIntString("Printer.Serial");

  public DevicePrinterESCPOS(PrinterWritter paramPrinterWritter, Codes paramCodes, UnicodeTranslator paramUnicodeTranslator)
    throws TicketPrinterException
  {
    this.m_CommOutputPrinter = paramPrinterWritter;
    this.m_codes = paramCodes;
    this.m_trans = paramUnicodeTranslator;
    this.m_CommOutputPrinter.init(ESCPOS.INIT);
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_CommOutputPrinter.init(this.m_codes.getInitSequence());
    this.m_CommOutputPrinter.write(this.m_trans.getCodeTable());
    this.m_CommOutputPrinter.flush();
  }

  public String getPrinterName()
  {
    return this.m_sName;
  }

  public String getPrinterDescription()
  {
    return null;
  }

  public JComponent getPrinterComponent()
  {
    return null;
  }

  public void reset()
  {
  }

  public void beginReceipt()
  {
  }

  public void printImage(BufferedImage paramBufferedImage)
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_CommOutputPrinter.write(this.m_codes.transImage(paramBufferedImage));
  }

  public void printBarCode(String paramString1, String paramString2, String paramString3)
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_codes.printBarcode(this.m_CommOutputPrinter, paramString1, paramString2, paramString3);
  }

  public void beginLine(int paramInt)
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    if (paramInt == 0)
      this.m_CommOutputPrinter.write(this.m_codes.getSize0());
    else if (paramInt == 1)
      this.m_CommOutputPrinter.write(this.m_codes.getSize1());
    else if (paramInt == 2)
      this.m_CommOutputPrinter.write(this.m_codes.getSize2());
    else if (paramInt == 3)
      this.m_CommOutputPrinter.write(this.m_codes.getSize3());
    else
      this.m_CommOutputPrinter.write(this.m_codes.getSize0());
  }

  public void printText(int paramInt, String paramString)
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    if ((paramInt & 0x1) != 0)
      this.m_CommOutputPrinter.write(this.m_codes.getBoldSet());
    if ((paramInt & 0x2) != 0)
      this.m_CommOutputPrinter.write(this.m_codes.getUnderlineSet());
    this.m_CommOutputPrinter.write(this.m_trans.transString(paramString));
    if ((paramInt & 0x2) != 0)
      this.m_CommOutputPrinter.write(this.m_codes.getUnderlineReset());
    if ((paramInt & 0x1) != 0)
      this.m_CommOutputPrinter.write(this.m_codes.getBoldReset());
  }

  public void endLine()
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
  }

  public void endReceipt()
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
    this.m_CommOutputPrinter.write(this.m_codes.getNewLine());
    this.m_CommOutputPrinter.write(this.m_codes.getCutReceipt());
    this.m_CommOutputPrinter.flush();
  }

  public void openDrawer()
  {
    this.m_CommOutputPrinter.write(ESCPOS.SELECT_PRINTER);
    this.m_CommOutputPrinter.write(this.m_codes.getOpenDrawer());
    this.m_CommOutputPrinter.flush();
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.escpos.DevicePrinterESCPOS
 * JD-Core Version:    0.6.0
 */